﻿using B.S.Database.Domain.Entity;
using B.S.Database.ErrorCode;
using B.S.Database.Interface.Interface;
using B.S.Database.Read.Api.Application.Commands.Traceability;
using MediatR;

namespace B.S.Database.Read.Api.Application.CommandHandler.Traceability
{
    public class GoodShowCommandHandler : IRequestHandler<GoodShowCommands, Apiresult<List<Goods_Infomation>>>
    {
        private readonly IBaseResotity<Goods_Infomation> goodResotity;

        public GoodShowCommandHandler(IBaseResotity<Goods_Infomation> GoodResotity)
        {
            goodResotity = GoodResotity;
        }
        public Task<Apiresult<List<Goods_Infomation>>> Handle(GoodShowCommands request, CancellationToken cancellationToken)
        {
            Apiresult<List<Goods_Infomation>> res = new Apiresult<List<Goods_Infomation>>();
            res.Code = ApiEnums.成功;
            res.Message = ApiEnums.成功.ToString();
            var list = goodResotity.GetAll();
            res.Data = list.ToList();
            return Task.FromResult(res);
        }
    }
}
